package com.example.mybaties.testone.bean_factory_processor;

import com.example.mybaties.testone.util.DesUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class EncryptPropertyPlaceHolderConfiger extends PropertyPlaceholderConfigurer {

    private Logger logger = LogManager.getLogger(this.getClass());

    @Override
    protected String convertProperty(String propertyName, String propertyValue) {
        if("username".equals(propertyName) || "password".equals(propertyName)){
            String decryptStr = DesUtil.getDecyptString(propertyValue);
            logger.debug("decryptStr = " + decryptStr);
            return decryptStr;
        }

        return super.convertProperty(propertyName, propertyValue);
    }
}
